#include <stdio.h>
#include <math.h>
#include <assert.h>


//#define DEBUG

#ifdef DEBUG
    #define ASSERT(cond)                                                                        \
    if (!(cond))                                                                                \
    {                                                                                           \
        printf("The statement is wrong: %s, file: %s, line: %d\n", #cond, __FILE__, __LINE__);  \
        abort();                                                                                \
    }
#else
    #define ASSERT(cond)
#endif //DEBUG


//#define _EJC

#ifdef  _EJC
    #define OUT if (0)
#else
    #define OUT
#endif // _EJC

int IsPrime (long num);

int main()
{
    int i = 0;
    int nNumbers = 0;
    long num_array[10000] = {0};

    OUT printf ("# This program finds prime numbers from all entered natural numbers\n"
                "  and prints them\n"
                "# The developer:    Yura Gorishniy     <strausmg@gmail.com>\n"
                "# Version 2.00\n"
                "# The file: %s\n"
                "# The compilation time: %s, %s\n\n", strrchr (__FILE__, '\\'), __DATE__, __TIME__);

    OUT printf ("# Enter the amount of numbers (type it and press ENTER)\n\n");
    if (scanf ("%d", &nNumbers) != 1)
        {
            printf ("Incorrect input, try again");
            return -1;
        }

    OUT printf ("\n" "# Enter all nubmers (natural) of your array (type them and press ENTER)\n\n");
    for (i = 0; i < nNumbers; ++i)
    {
        if (scanf ("%ld", &num_array[i])!= 1)
            {
                printf ("Incorrect input, try again");
                return -1;
            }

        if (IsPrime (num_array[i])) printf ("%ld ", num_array[i]);
    }

return 0;
}

int IsPrime (long num)
{
    if (num == 1) return 0;
    if (num == 2) return 1;
    if (num % 2 == 0) return 0;

    long sqrt_num = floor (sqrt (num));
    long divisor = 0;

    for (divisor = 3; divisor <= sqrt_num; divisor += 2)
        if (num % divisor == 0) return 0;

return 1;
}

